package com.woniu.controller;

import com.woniu.service.PatientExamService;
import com.woniu.utils.ResponseUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/patientExam")
public class PatientExamController {
    @Resource
    private PatientExamService patientExamService;

    @GetMapping("/list")
    public ResponseUtil selectAll(@RequestParam(defaultValue = "1") Integer pageNum,
                                  @RequestParam(defaultValue = "10") Integer pageSize) {
        return patientExamService.findAll(pageNum, pageSize);
    }

    @GetMapping("/search")
    public ResponseUtil selectByCondition(@RequestParam(required = false) String patientName,
                                          @RequestParam(required = false) String itemName,
                                          @RequestParam(required = false) Integer statusInt,
                                          @RequestParam(defaultValue = "1") Integer pageNum,
                                          @RequestParam(defaultValue = "10") Integer pageSize) {
        return patientExamService.selectByCondition(patientName,itemName, statusInt, pageNum, pageSize);
    }

    @PostMapping("/complete")
    public ResponseUtil completeExam(@RequestBody Map<String, Object> request) {
        Integer id = (Integer) request.get("id");
        String result = (String) request.get("result");
        Integer statusInt = (Integer) request.get("statusInt");
        return patientExamService.completeExam(id, result,statusInt);
    }
}
